	
	 
<script type="text/javascript">
	$(function(){
		searchData = function (){
			//ambil nilai-nilai filter
			var periode = $("#periode").val();
			var kode_wil = $("#kode_wil").val();
			var jenis_kb = $("#jenis_kb").val();
			
			var gridUrl = "<?=base_url()?>piutang_pajak_per_kb/grid/"+periode+"/"+kode_wil+"/"+jenis_kb;
			
			$('#dg').datagrid({
				url:gridUrl,
				queryParams:{lastNo:'0'},	
				pageNumber : 1,
				onLoadSuccess:function(data){	
					$('#dg').datagrid('options').queryParams.lastNo = data.lastNo;
			}});
		}	 
		
		searchData();
	});
	
	function laporan_langsung(pageURL, title,w,h){

		var periode=document.getElementById('periode').value;
		var kode_wil=document.getElementById('kode_wil').value;
		var jenis_kb=document.getElementById('jenis_kb').value;
		 var site 		= "<?php echo site_url()?>";
		if ((kode_wil=='')||(jenis_kb==''))
		{
			alert('Isilah Kode Wilayah / Jenis Kendaraan');
		}
		else
		{
			//var left = (screen.width/2)-(w/2);
			//var top = (screen.height/2)-(h/2);
			//var targetWin = window.open ('<?=site_url();?>/laporan/report/'+periode+'/'+kode_wil+'/'+jenis_kb, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
			location.href = site+"/piutang_pajak_per_kb/report_pdf_langsung/"+periode+'/'+kode_wil+'/'+jenis_kb;
			document.getElementById('tanggal_awal').value='';
			document.getElementById('tanggal_akhir').value='';

		}
	}
 
	function laporan_preview(pageURL, title,w,h){

		var periode=document.getElementById('periode').value;
		var kode_wil=document.getElementById('kode_wil').value;
		var jenis_kb=document.getElementById('jenis_kb').value;
		 var site 		= "<?php echo site_url()?>";
		if ((kode_wil=='')||(jenis_kb==''))
		{
			alert('Isilah Kode Wilayah / Jenis Kendaraan');
		}
		else
		{
			var left = (screen.width/2)-(w/2);
			var top = (screen.height/2)-(h/2);
			var targetWin = window.open ('<?=site_url();?>/piutang_pajak_per_kb/report_pdf_preview/'+periode+'/'+kode_wil+'/'+jenis_kb, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
			//location.href = site+"/piutang_pajak_per_kb/report_pdf/"+periode+'/'+kode_wil+'/'+jenis_kb;
			document.getElementById('tanggal_awal').value='';
			document.getElementById('tanggal_akhir').value='';

		}
	}
	 

</script>

 
		
 
	 

<section class="grid_12">
	<div class="block-border">
		<?php 
		$attributes = array('name' => 'form1', 'id' => 'form1', 'class'=>'block-content form');
		echo form_open_multipart('piutang_pajak_per_kb/index', $attributes);
		?>
			<h1>Piutang Pajak Per Kendaraan Bermotor</h1>
			
			<div class="block-controls">
				
				<ul class="controls-buttons">
						<td width='15%'>
							Tahun:&nbsp;<input type=text name='periode' id='periode' size="4" value=<?=date('Y')?>>
						</td> 
						<td>
								<select name="kode_wil" id="kode_wil" >
									<option value="">--Pilih Wilayah--</option>
									<?php
										foreach($kode_wil->result()  as $row)
										{
											echo '<option value="'.$row->kd_wilayah.'">'.$row->kd_wilayah.'-'.$row->nm_wilayah.'</option>';
										}						
									?>
									<option value="all">SEMUA WILAYAH</option>
								</select>
						</td>		
						<td>		
								<select name="jenis_kb" id="jenis_kb" >
									<option value="">--Pilih JENIS KENDARAAN--</option>
									<?php
										foreach($jenis_kb->result()  as $row)
										{
											echo '<option value="'.$row->kode.'">'.$row->kode.'-'.$row->uraian.'</option>';
										}						
									?>
									<option value="all">SEMUA JENIS KENDARAAN</option>
								</select>
						</td>
				 
						<td>
							<button type='button' name='' value='Lihat' style='cursor:pointer' onclick="searchData()">VIEW</button>
							<button type="button" onclick="laporan_preview('<?=site_url();?>/piutang_pajak_per_kb/index/','name',800,600)"><img src="<?=base_url()?>asset/admin/images/icons/fugue/tick-circle.png" width="16" height="16">Print Preview</button> 

							<!--<button type="button" onclick="laporan_langsung()">REKAP PDF</button>-->
						</td>
				 
					<li class="sep"></li>
					<li> </li>
				</ul>
				
			</div>
		
			<div class="no-margin">
			<table id="dg" class="easyui-datagrid" width="100%" style="height:auto;width:auto" fitColumns="true" singleSelect="true" rownumbers="false" pagination="false" showFooter="true">
			  <thead>
			  <tr>
				<th field="num" width="20px">Nomor</th>
						<th field="nama" sortable="true" width="100px">NAMA /<br> ALAMAT</th>
						<th field="wilayah" sortable="true" width="100px">WILAYAH</th>
						<th field="detail" sortable="true" width="100px">DETAIL KENDARAN</th>
						<th  field="pkb" width="70px">PKB </th>
						<th field="pkb_den" width="70px">PKB DENDA</th>
						<th  field="pkb_tgk" width="70px">PKB TUNGGAKAN</th>
						<th field="pkb_tgk_den" width="70px">PKB TUNGGAKAN DENDA</th>
					  <th  field="swdkllj" width="70px">SWDKLLJ</th>
					  <th  field="swdkllj_den" width="70px">SWDKLLJ DENDA</th>
					  <th  field="swdkllj_tgk" width="70px">SWDKLLJ TUNGGAKAN</th>
					  <th  field="swdkllj_tgk_den" width="70px">SWDKLLJ TUNGGAKAN DENDA</th>
					  <th  field="piutang" width="70px">TOTAL PIUTANG</th>
					  <th field="sudah_bayar" width="70px" >YANG SUDAH BAYAR</th>
					    <th field="sisa_bayar" width="70px" >SISA PAJAK</th>
			  </tr>
			  </thead> 
			</table>
			
			<!-- Recent Table 
			<table class="table" cellspacing="0" width="100%">
			
				<thead>
					<tr> 
						<!--<th align="left" valign="top" scope="col">&nbsp;</th>
						<th align="left" valign="top" scope="col">Nomor</th>
						<th align="left" valign="top" scope="col">WILAYAH</th>
						<th align="left" valign="top" scope="col">JENIS</th>
						<th align="left" valign="top" scope="col">PIUTANG PAJAK</th>
						<th align="left" valign="top" scope="col">YANG SUDAH BAYAR</th>
						<th align="left" valign="top" scope="col">SISA PAJAK</th> 
					</tr>
				</thead>
				
				<tbody>
					
					<?php /*
					$i=0;
					$j=0;
					$sum_piutang = 0; 
					$sum_sudah_bayar = 0; 
					$sum_sisa = 0; 
				//	$row = $getItemCount->num_rows();
					
					foreach($getItemCount->result() as $row) {$j=$j+1; } 
					$getItemCount = $j;
					//echo $getItemCount; echo '<<'; echo '<br/>';
					
					
					for($x=0;$x<=$getItemCount-1;$x++){
					
					$i = $i+1;
					//foreach($piutang->result() as $row1)echo $row1->piutang;echo'<br/>';echo'<br/>';
					//foreach($sudah_bayar->result_array() as $row2) echo $row2[1]['sudah_bayar'];echo'<br/>';
					
					$row1 = $results->result_array(); 
						//echo $x.'-'. $row1[$x]['kd_wilayah'].'-'.$row1[$x]['nm_wilayah'].'-'.$row1[$x]['kd_jenis_kb'].'-'.$row1[$x]['uraian'];  
					$row2 = $piutang->result_array(); 
						//echo $x.'-'. $row2[$x]['kd_wilayah'].'-'.$row2[$x]['kd_jenis_kb'].'-'.$row2[$x]['piutang'];  
					$row3 = $sudah_bayar->result_array();
						//echo $x.'-'. $row2[$x]['kd_wilayah'].'-'.$row2[$x]['kd_jenis_kb'].'-'. $row3[$x]['sudah_bayar'];echo'<br/>'; */
					?>
					<tr>
						<td align="left" valign="top"><?=$i ?> </td>
						<td align="left" valign="top"><?=$row1[$x]['kd_wilayah'];?> - <?=$row1[$x]['nm_wilayah'];?> </td>
						<td align="left" valign="top"><?=$row1[$x]['kd_jenis_kb'];?> - <?=$row1[$x]['uraian'];?> </td>
						<td align="right" valign="top"><?=/*$row2[$x]['kd_wilayah'].'-'.$row2[$x]['kd_jenis_kb'].'-'.*/convert_rupiah_non_rp($row2[$x]['piutang']);?></td>
						<td align="right" valign="top"><?=/*$row2[$x]['kd_wilayah'].'-'.$row2[$x]['kd_jenis_kb'].'-'.*/convert_rupiah_non_rp($row3[$x]['sudah_bayar']);?> </td>
						<td align="right" valign="top"><?=convert_rupiah_non_rp(($row2[$x]['piutang']-$row3[$x]['sudah_bayar']));?> </td>
						
					</tr>	
					<?/*
						$sum_piutang = $sum_piutang + $row2[$x]['piutang']; 
						$sum_sudah_bayar = $sum_sudah_bayar + $row3[$x]['sudah_bayar']; 
						$sum_sisa = $sum_sisa + ($row2[$x]['piutang']-$row3[$x]['sudah_bayar']); 
					}*/
					?>
					<tr>
							<td colspan="3"><b>JUMLAH : </b></td> 
							<td align="right"><b><?=convert_rupiah_non_rp($sum_piutang);?></b></td>
							<td align="right"><b><?=convert_rupiah_non_rp($sum_sudah_bayar);?></b></td>
							<td align="right"><b><?=convert_rupiah_non_rp($sum_sisa);?></b></td>
							 
						</tr>	
					  
						<tr>
							<td colspan="6">&nbsp;</td>
						</tr>	
				</tbody>
			
			</table>
			-->
			</div>
		</form>
	</div>
</section>	
